#!/usr/bin/env make
###############################################################################
#
#  Copyright (c) Hunan Goke,Chengdu Goke,Shandong Goke. 2021.
#  All rights reserved.
#  Create By Caizhiyong 2021/3/16
#
###############################################################################

EUDEV := eudev-3.2.7

EUDEV_PREFIX = $(ROOTFS_BUILDDIR)/$(EUDEV)/.install

rootfs_unstrip: $(ROOTFS_PREFIX)/sbin/udevd

clean: $(EUDEV).clean

$(EUDEV).clean:
	rm -rf $(ROOTFS_BUILDDIR)/$(EUDEV)

$(ROOTFS_PREFIX)/sbin/udevd: $(ROOTFS_BUILDDIR)/$(EUDEV)/.built
	$(call mkdir,$(@D))
	cp -af $(ROOTFS_BUILDDIR)/$(EUDEV)/src/udev/udevd $(ROOTFS_PREFIX)/sbin
	cp -af $(ROOTFS_BUILDDIR)/$(EUDEV)/src/udev/udevadm $(ROOTFS_PREFIX)/bin
	tar -xf $(ROOTFS_SRCDIR)/eudev/rootfs.tar.bz2 -C $(ROOTFS_PREFIX)/..
	touch $@

$(ROOTFS_BUILDDIR)/$(EUDEV)/.built: $(ROOTFS_BUILDDIR)/$(EUDEV)/.extracted
	cd $(<D); CC=$(CROSS_COMPILE)-gcc ./configure \
		--prefix=/ \
		--host=$(CROSS_COMPILE) --disable-extras \
		--disable-introspection
	make -C $(<D) USE_STATIC=false
	touch $@

$(ROOTFS_BUILDDIR)/$(EUDEV)/.extracted:
	$(call mkdir,$(@D))
	tar xf $(OPEN_SOURCE_DIR)/eudev/$(EUDEV).tar.gz -C $(ROOTFS_BUILDDIR)
	cp -arf $(ROOTFS_SRCDIR)/eudev/$(EUDEV).patch/. $(@D)
	touch $@
